<?php
    class Quanlyloaiduan_model extends CI_Model {
        function __construct() {
            parent::__construct();
            $this->load->helper('url');
            $this->load->database();
        }
        
        function getDanhSachLoaiDuAn() {
            $query = $this->db->get("loaiduan");
            return $query->result();
        }
        
        function getLoaiDuAn() {
            //something in here 
        }
        
        function suaLoaiDuAn($data) {
            $this->db->where('MaLoaiDuAn', "{$data['MaLoaiDuAn']}");
            $this->db->update('loaiduan', $data);
        }
        
        function themLoaiDuAn($data) {
            $this->db->insert('loaiduan', $data);
            $query = $this->db->get_where('loaiduan', 'MaLoaiDuAn = LAST_INSERT_ID()');
            return $query->result();
        }
        
        function xoaLoaiDuAn($idLoaiDuAn) {
            $this->db->delete('loaiduan', array('MaLoaiDuAn'=>$idLoaiDuAn));
        }
    }
    
?>